package com.ybwh.springboot1;

import java.io.File;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;

import javax.sql.DataSource;

/**
 * 消息系统移动端接口启动类
 *
 */
@SpringBootApplication(exclude = JtaAutoConfiguration.class)
@ServletComponentScan(basePackages = { "com.ybwh.springboot1" })
public class Application {
	private static final Logger logger = LoggerFactory.getLogger(Application.class);

	public static void main(String[] args) {

		ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);

		logger.error("----------------error-----------------");
		logger.warn("----------------warn-----------------");
		logger.info("----------------info-----------------");
		logger.debug("----------------debug-----------------");
		logger.trace("----------------trace-----------------");
		System.out.println();

		String configPath = context.getEnvironment().getProperty("spring.config.location");
		String tomcatPort = context.getEnvironment().getProperty("server.port");
		System.out.println(configPath + "," + tomcatPort);


		String[] beanNames = context.getBeanDefinitionNames();
//		context.getBeanNamesForType();
		//String[] beanNames = context.getBeanNamesForAnnotation(RestController.class);//所有添加该注解的bean
		logger.info("bean总数:{}", context.getBeanDefinitionCount());
		int i = 0;
		for (String str : beanNames) {
			logger.info("{},beanName:{}", ++i, str);
		}


//		String[] beans = context.getBeanNamesForType(DataSource.class);
//
//		for (String str : beans) {
//			logger.info("beanName:{}", str);
//		}
	}


}
